<template>
  <page-header-wrapper>
    <a-card class="top_card" :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="20">
            <a-col :md="5" :sm="24">
              <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input v-model="queryParam.keyword" style="width: 100%" placeholder="请输入" />
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="24">
              <a-form-item label="订单类型">
                <a-select placeholder="请选择" v-model="queryParam.orderWaimai" default-value="1">
                  <a-select-option value="1">全部</a-select-option>
                  <a-select-option value="2">普通订单</a-select-option>
                  <a-select-option value="4">外卖订单</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="24">
              <a-form-item label="订单时间">
                <a-config-provider :locale="locale">
                  <a-range-picker
                    format="YYYY-MM-DD HH:mm:ss"
                    style="width: 100%"
                    @change="onChange"
                    @calendarChange="calendarChange"
                    :ranges="ranges"
                  />
                </a-config-provider>
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="24">
              <a-form-item label="来源平台">
                <a-select v-model="queryParam.platform" placeholder="请选择" default-value="">
                  <a-select-option value="">全部</a-select-option>
                  <a-select-option value="0">微信小程序</a-select-option>
                  <a-select-option value="2">微信公众号</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>

            <a-col :md="4" :sm="24">
              <span class="table-page-search-submitButtons" :style="{ float: 'right', overflow: 'hidden' }">
                <a-button style="margin-right: 8px" @click="() => (this.queryParam = { status: this.tabKey })"
                  >重置</a-button
                >
                <a-button type="primary" @click="refresh">查询</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card style="margin-top: 10px" :bordered="false" title="消息提醒">
      <div slot="extra"><a-button type="primary" icon="plus">新建</a-button></div>
      <s-table
        ref="tableList"
        size="default"
        :rowSelection="{ selectedRowKeys: this.selectedRowKeys, onChange: this.onSelectChange }"
        row-key="id"
        :columns="columns"
        :data="loadData"
      >
        <template slot="name" slot-scope="text, record">
          <a-row :gutter="20">
            <a-col span="4">
              <img :src="record.pic_list[0]" style="width: 100%; border-radius: 5px" />
            </a-col>
            <a-col span="20">
              <a-tooltip>
                <template slot="title">
                  {{ record.goods_name }}
                </template>
                <div class="over_e">{{ record.goods_name }}</div>
              </a-tooltip>
              <div>{{ record.created_at }}</div>
            </a-col>
          </a-row>
        </template>
        <template slot="action" slot-scope="text, record">
          <a-button type="link"> 编辑 </a-button>
          <a-divider type="vertical" />
          <a-dropdown>
            <a> 更多 <a-icon type="down" /> </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a href="javascript:;">first</a>
              </a-menu-item>
              <a-menu-item>
                <a href="javascript:;">second</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </template>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
const columns = [
  {
    title: '商品ID',
    dataIndex: 'id',
    key: 'id',
    width: 100,
  },
  {
    title: '产品名称',
    dataIndex: 'name',
    key: 'name',
    width: 320,
    scopedSlots: { customRender: 'name' },
  },
  {
    title: '用户',
    dataIndex: 'virtual_user',
    key: 'virtual_user',
    width: 120,
  },
  {
    title: '评分',
    dataIndex: 'score',
    key: 'score',
    width: 120,
  },
  {
    title: '详情',
    dataIndex: 'content',
    key: 'content',
    width: 120,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 150,
    scopedSlots: { customRender: 'action' },
  },
]
import { STable } from '@/components'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import moment from 'moment'
import { getComment } from '@/api/order'
export default {
  name: 'OrderList',
  components: {
    STable,
  },
  data() {
    return {
      columns,
      selectedRowKeys: [],
      loadData: (parameter) => {
        Object.assign(parameter, {})
        return getComment(parameter).then((res) => {
          return res.data
        })
      },
      ranges: {
        一月内: () => [moment().startOf('day').subtract(1, 'month'), moment()],
        昨天: () => [moment().startOf('day').subtract(1, 'days'), moment().endOf('day').subtract(1, 'days')],
        最近一周: () => [moment().startOf('day').subtract(1, 'weeks'), moment()],
      },
      locale: zhCN,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      queryParam: {},
      selectDate: {},
      totalCount: 0,
    }
  },
  watch: {},
  created() {},
  activated() {},
  computed: {},
  filters: {},
  methods: {
    moment,
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys
    },
    refresh(row) {
      this.$nextTick(() => {
        this.$refs.tableList.refresh(true)
      })
    },
    calendarChange(date, dateString) {
      this.selectDate = date[0]
    },
    onChange(date, dateString) {
      this.queryParam.dateStart = dateString[0]
      this.queryParam.dateEnd = dateString[1]
    },
  },
}
</script>
<style lang="less" scoped>
/deep/.ant-card-head {
  border-bottom: none;
}
.over_e {
  width: 80%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>
